package Control;

import java.util.ArrayList;

import javax.swing.ImageIcon;
import javax.swing.JOptionPane;

import Entity.MsgPackage;
import GUI.FreezesManagement_GUI;
import GUI.ScreenManager;

public class Unfreeze_Control {
	private FreezesManagement_GUI f_gui;
	private ArrayList<Integer> arr;
	private MsgPackage msg;
	 public Unfreeze_Control(){
		f_gui=new FreezesManagement_GUI();
		arr=new ArrayList<Integer>();
	    msg=new MsgPackage();
	}
	
	
	public void unfreeze_pressed(Integer req_num){
		msg.setObject(req_num);
		msg.setOp_code(OP_CODE.UNFREEZE_REQ);
		ScreenManager.getConnection().accept(msg);
	
		Object o = ScreenManager.getConnection().cclient.getMessage();
		Boolean a=(Boolean) o;
		if(!a){
			JOptionPane.showMessageDialog(	null, "The system was Unable to unfreeze the request", "Error", JOptionPane.ERROR_MESSAGE);	
		}
		else{
			JOptionPane.showMessageDialog(	null, "There request was unfrezzed succefuly", "", JOptionPane.INFORMATION_MESSAGE);	

		}
		}
	
		

		public ArrayList <Integer> show_gui_screen(){
			msg.setObject(null);
			msg.setOp_code(OP_CODE.GET_UNFREEZE_REQ);
			ScreenManager.getConnection().accept(msg);
		
			Object o = ScreenManager.getConnection().cclient.getMessage();

			arr= (ArrayList<Integer>)o;
			if(arr.size()==0){
				JOptionPane.showMessageDialog(	null, "There are no frozen requests", "Error", JOptionPane.ERROR_MESSAGE);	
               return null;}
			
			return arr;}
                
		
	
	public MsgPackage getMsg() {
		return msg;
	}

	public void setMsg(MsgPackage msg) {
		this.msg = msg;
	}

	
	public FreezesManagement_GUI getF_gui() {
		return f_gui;
	}
	public void setF_gui(FreezesManagement_GUI f_gui) {
		this.f_gui = f_gui;
	}
	public ArrayList<Integer> getArr() {
		return arr;
	}
	public void setArr(ArrayList<Integer> arr) {
		this.arr = arr;
	}

}
